//复制链接点击效果
(function ($) {
    $.extend({
        tipsBox: function (options) {
            options = $.extend({
                obj: null,  //jq对象，要在那个html标签上显示
                str: "复制成功",  //字符串，要显示的内容;也可以传一段html，如: "<b style='font-family:Microsoft YaHei;'>+1</b>"
                startSize: "12px",  //动画开始的文字大小
                endSize: "30px",    //动画结束的文字大小
                interval: 600,  //动画时间间隔
                color: "#c2e9f5",    //文字颜色
                callback: function () { }    //回调函数
            }, options);
            $("body").append("<span class='num'>" + options.str + "</span>");
            var box = $(".num");
            var left = options.obj.offset().left + options.obj.width() / 2;
            var top = options.obj.offset().top - options.obj.height();
            box.css({
                "position": "absolute",
                "left": left + "px",
                "top": top + "px",
                "z-index": 9999,
                "font-size": options.startSize,
                "line-height": options.endSize,
                "color": options.color
            });
            box.animate({
                "font-size": options.endSize,
                "opacity": "0",
                "top": top - parseInt(options.endSize) + "px"
            }, options.interval, function () {
                box.remove();
                options.callback();
            });
        }
    });
})(jQuery);

function niceIn(prop){
    prop.find('i').addClass('niceIn');
    setTimeout(function(){
        prop.find('i').removeClass('niceIn');
    },1000);
}
$(function () {
    $("#btn").click(function () {
        $.tipsBox({
            obj: $(this),
            str: "复制成功",
            callback: function () {
            }
        });
        niceIn($(this));
    });
});
//复制链接点击效果
//发表评论
function Comment_fun() {
    $.ajax({
        type: "POST",
        url: $("#commentajaxurl").val(),
        data: {
            id : $("#articleaid").val(),
            content : $("#content").val()
        },
        dataType:"json",

        success: function(data){
            var data = JSON.parse(data);
            alert(data.msg);
        },
        error:function(XMLHttpRequest, textStatus, errorThrown){ //上传失败
            alert("status:"+XMLHttpRequest.status);
            alert("readyState:"+XMLHttpRequest.readyState);
            alert(textStatus);
        }
    });
};
var $pointadd = $("#pointadd");
$pointadd.one("click",function(){
    var $id = this.getAttribute("data-id");
    if($id){
        $.ajax({
            type: "POST",
            url: $("#pointaddajaxurl").val(),
            data: {
                id : $("#pointadd").data("id")
            },
            dataType:"text",

            success: function(data){
                var data2 = JSON.parse(data);
                $(".point").text(data2['0'].point)
                //console.log(data2['0'].point)
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){ //上传失败
                alert("status:"+XMLHttpRequest.status);
                alert("readyState:"+XMLHttpRequest.readyState);
                alert(textStatus);
            }
        });
    }
    $.tipsBox({
        obj: $(this),
        str: "+1",
        color:"red",
        callback: function () {
        }
    });
    niceIn($(this));
});

$('.circleCode').on('click',function () {
    $('.pop_box').show();
    var $thisId = $(this).attr('data-id');
    if($thisId){
        $.ajax({
            type: "POST",
            url: $("#circleCodeajaxurl").val(),
            data: {
                id : $thisId
            },
            dataType:"json",

            success: function(data){
                $("#popCodeCon > img").attr("src",data.pic_url);
                $("#popCodeCon > p").text(data.title);
                $("#popCodeCon > span").text(data.desc);
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){ //上传失败
                alert("status:"+XMLHttpRequest.status);
                alert("readyState:"+XMLHttpRequest.readyState);
                alert(textStatus);
            }
        });
    }else{
        alert('id错误');
    }
});
function popBoxHide_fun() {
    $('.pop_box').hide();
};

//复制函数
function copy_fun() {
    var test = new clipBoard(document.getElementById('windowhref'), {
        copy: function() {
            return document.getElementById('windowhref').innerText;

        }
    });
};
function hfdis_fun(btn,cl) {
    $(btn).on("click",function(){
        $(this).parent("li").find($(cl)).toggle();
    })
}hfdis_fun($(".hfdis-fun"),$(".hfdis"));
hfdis_fun($(".hfdis-fun2"),$(".hfdis2"));

function windowhref_fun() {
    var winhre = window.location.href;
    $("#windowhref").html('<a style="color: #c9ccd0" href="'+winhre+'">'+winhre+'</a>');
}windowhref_fun();